package com.ruoyi.web.controller.youtobe;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.youtobe.domain.YoutobeVideoLable;
import com.ruoyi.youtobe.service.IYoutobeVideoLableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Youtobe视频标签Controller
 *
 * @author ruoyi
 * @date 2025-11-16
 */
@RestController
@RequestMapping("/youtobe/lable")
public class YoutobeVideoLableController extends BaseController {
    @Autowired
    private IYoutobeVideoLableService youtobeVideoLableService;

    /**
     * 查询Youtobe视频标签列表
     */
    @GetMapping("/list")
    public TableDataInfo list(YoutobeVideoLable youtobeVideoLable) {
        startPage();
        List<YoutobeVideoLable> list = youtobeVideoLableService.selectYoutobeVideoLableList(youtobeVideoLable);
        TableDataInfo dataTable = getDataTable(list);

        return dataTable;
    }

    /**
     * 导出Youtobe视频标签列表
     */
    @Log(title = "Youtobe视频标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YoutobeVideoLable youtobeVideoLable) {
        List<YoutobeVideoLable> list = youtobeVideoLableService.selectYoutobeVideoLableList(youtobeVideoLable);
        ExcelUtil<YoutobeVideoLable> util = new ExcelUtil<YoutobeVideoLable>(YoutobeVideoLable.class);
        util.exportExcel(response, list, "Youtobe视频标签数据");
    }

    /**
     * 获取Youtobe视频标签详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(youtobeVideoLableService.selectYoutobeVideoLableById(id));
    }

    /**
     * 新增Youtobe视频标签
     */
    @Log(title = "Youtobe视频标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YoutobeVideoLable youtobeVideoLable) {
        return toAjax(youtobeVideoLableService.insertYoutobeVideoLable(youtobeVideoLable));
    }

    @Log(title = "男频女频全部标签获取", businessType = BusinessType.INSERT)
    @PostMapping("all")
    public AjaxResult addAll( ) {
        return toAjax(youtobeVideoLableService.insertYoutobeVideoAllLable());
    }
    /**
     * 修改Youtobe视频标签
     */
    @Log(title = "Youtobe视频标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YoutobeVideoLable youtobeVideoLable) {
        return toAjax(youtobeVideoLableService.updateYoutobeVideoLable(youtobeVideoLable));
    }

    /**
     * 删除Youtobe视频标签
     */
    @Log(title = "Youtobe视频标签", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(youtobeVideoLableService.deleteYoutobeVideoLableByIds(ids));
    }
}
